package org.weso.acota.enhacer;

import org.apache.log4j.Logger;
import org.weso.acota.dao.SuggestDAO;
import org.weso.acota.dao.SuggestGoogleDAOImpl;
import org.weso.acota.to.ProviderTO;

public class GoogleEnhancer extends EnhancerAdapter {


	private static SuggestDAO googleDAO = new SuggestGoogleDAOImpl();
	protected static Logger logger = Logger.getLogger(GoogleEnhancer.class);
	
	@Override
	protected void execute() throws Exception {	
		logger.debug("Initializes variables to add suggestions");
		this.suggest = this.request.getSuggestions();
		logger.info("Access to Google data");
		this.suggest = googleDAO.suggest(request);
	}

	@Override
	protected void preExecute() throws Exception {
		// TODO Auto-generated method stub
		
	}

	@Override
	protected void postExecute() throws Exception {
		logger.debug("Add providers to request");
		this.request.getTargetProviders().add(googleDAO.getProvider());
	}

	public static ProviderTO getDefaultProvider() throws Exception {
		logger.info("Get Google provider");
		return googleDAO.getProvider();
	}

}
